From 3a852a0f2a7b2d88f46254aa9915976b480d6f3a Mon Sep 17 00:00:00 2001 From: mcarton Date: Fri, 15 Jan 2016 15:51:25 +0100 Subject: [PATCH] Remove useless returns MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix most of Clippy’s needless_return warnings. Remaining cases are false positives. --- src/cargo/core/resolver/mod.rs | 2 +- src/cargo/core/shell.rs | 4 ++-- src/cargo/ops/cargo_compile.rs | 6 +++--- src/cargo/ops/cargo_rustc/context.rs | 8 ++++---- src/cargo/ops/cargo_rustc/custom_build.rs | 2 +- src/cargo/ops/cargo_rustc/fingerprint.rs | 2 +- src/cargo/sources/git/source.rs | 2 +- src/cargo/sources/path.rs | 4 ++-- src/cargo/sources/registry.rs | 2 +- src/cargo/util/config.rs | 2 +- src/cargo/util/sha256.rs | 8 ++++---- src/cargo/util/vcs.rs | 6 +++--- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 547d7e23f..5e2dc39a0 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -384,7 +384,7 @@ fn find_candidate(backtrack_stack: &mut Vec, return Some(candidate) } } - return None + None } #[allow(deprecated)] // connect => join in 1.3 diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index 5c03d34c1..5a50a9886 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -81,7 +81,7 @@ impl MultiShell { where F: FnMut(&mut MultiShell) -> io::Result<()> { match self.verbosity { - Verbose => return callback(self), + Verbose => callback(self), _ => Ok(()) } } @@ -91,7 +91,7 @@ impl MultiShell { { match self.verbosity { Verbose => Ok(()), - _ => return callback(self) + _ => callback(self) } } diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index f80e3db2b..43995c0d0 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -257,7 +257,7 @@ pub fn compile_pkg<'a>(root_package: &Package, ret.to_doc_test = to_builds.iter().map(|&p| p.clone()).collect(); - return Ok(ret); + Ok(ret) } impl<'a> CompileFilter<'a> { @@ -311,7 +311,7 @@ fn generate_targets<'a>(pkg: &'a Package, CompileMode::Build => build, CompileMode::Doc { .. } => &profiles.doc, }; - return match *filter { + match *filter { CompileFilter::Everything => { match mode { CompileMode::Bench => { @@ -379,7 +379,7 @@ fn generate_targets<'a>(pkg: &'a Package, } Ok(targets) } - }; + } } /// Read the `paths` configuration variable to discover all path overrides that diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index a1bc8b3a6..716e04490 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -159,7 +159,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { self.compilation.deps_output = self.layout(root, Kind::Target).proxy().deps().to_path_buf(); - return Ok(()); + Ok(()) } /// Returns the appropriate directory layout for either a plugin or not. @@ -283,7 +283,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } } assert!(ret.len() > 0); - return Ok(ret); + Ok(ret) } /// For a package, return all targets which are registered as dependencies @@ -374,7 +374,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } })); } - return ret + ret } /// Returns the dependencies needed to run a build script. @@ -462,7 +462,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { if unit.target.is_bin() { ret.extend(self.maybe_lib(unit)); } - return ret + ret } /// If a build script is scheduled to be run for the package specified by diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index 9b974ab1c..ea06cf570 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -399,6 +399,6 @@ pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>, let prev = out.entry(*unit).or_insert(BuildScripts::default()); prev.to_link.extend(to_link); prev.plugins.extend(plugins); - return prev + prev } } diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index 1cd37c33c..66f0fb0dd 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -141,7 +141,7 @@ impl Fingerprint { } let ret = util::hash_u64(self); *self.memoized_hash.lock().unwrap() = Some(ret); - return ret + ret } fn compare(&self, old: &Fingerprint) -> CargoResult<()> { diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index eaf66adcc..e2829ad5b 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -145,7 +145,7 @@ pub fn canonicalize_url(url: &Url) -> Url { _ => {} } - return url; + url } impl<'cfg> Debug for GitSource<'cfg> { diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 91162a5fe..1cbead449 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -244,7 +244,7 @@ impl<'cfg> PathSource<'cfg> { let loc = pkg.root(); try!(PathSource::walk(loc, &mut ret, true, filter)); } - return Ok(ret); + Ok(ret) } fn walk(path: &Path, ret: &mut Vec, @@ -275,7 +275,7 @@ impl<'cfg> PathSource<'cfg> { } try!(PathSource::walk(&dir, ret, false, filter)); } - return Ok(()) + Ok(()) } } diff --git a/src/cargo/sources/registry.rs b/src/cargo/sources/registry.rs index 7a7822a67..9bce0dc25 100644 --- a/src/cargo/sources/registry.rs +++ b/src/cargo/sources/registry.rs @@ -561,7 +561,7 @@ impl<'cfg> Source for RegistrySource<'cfg> { for src in self.sources.values() { ret.extend(try!(src.get(packages)).into_iter()); } - return Ok(ret); + Ok(ret) } fn fingerprint(&self, pkg: &Package) -> CargoResult { diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 474b174f1..88a42383b 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -469,7 +469,7 @@ fn homedir(cwd: &Path) -> Option { cwd.join(home) }); let user_home = env::home_dir().map(|p| p.join(".cargo")); - return cargo_home.or(user_home); + cargo_home.or(user_home) } fn walk_tree(pwd: &Path, mut walk: F) -> CargoResult<()> diff --git a/src/cargo/util/sha256.rs b/src/cargo/util/sha256.rs index 3a6dc5055..18a258af3 100644 --- a/src/cargo/util/sha256.rs +++ b/src/cargo/util/sha256.rs @@ -36,7 +36,7 @@ mod imp { let ret = Sha256 { ctx: ctx }; let n = EVP_DigestInit_ex(ret.ctx, EVP_sha256(), 0 as *mut _); assert_eq!(n, 1); - return ret; + ret } } @@ -55,7 +55,7 @@ mod imp { let n = EVP_DigestFinal_ex(self.ctx, ret.as_mut_ptr(), &mut out); assert_eq!(n, 1); assert_eq!(out, 32); - return ret; + ret } } } @@ -104,7 +104,7 @@ mod imp { CryptCreateHash(ret.hcryptprov, CALG_SHA_256, 0, 0, &mut ret.hcrypthash) }); - return ret; + ret } pub fn update(&mut self, bytes: &[u8]) { @@ -122,7 +122,7 @@ mod imp { &mut len, 0) }); assert_eq!(len as usize, ret.len()); - return ret; + ret } } diff --git a/src/cargo/util/vcs.rs b/src/cargo/util/vcs.rs index 16fc72333..ffd260680 100644 --- a/src/cargo/util/vcs.rs +++ b/src/cargo/util/vcs.rs @@ -10,7 +10,7 @@ pub struct GitRepo; impl GitRepo { pub fn init(path: &Path, _: &Path) -> CargoResult { try!(git2::Repository::init(path)); - return Ok(GitRepo) + Ok(GitRepo) } pub fn discover(path: &Path, _: &Path) -> Result { git2::Repository::discover(path) @@ -20,11 +20,11 @@ impl GitRepo { impl HgRepo { pub fn init(path: &Path, cwd: &Path) -> CargoResult { try!(process("hg").cwd(cwd).arg("init").arg(path).exec()); - return Ok(HgRepo) + Ok(HgRepo) } pub fn discover(path: &Path, cwd: &Path) -> CargoResult { try!(process("hg").cwd(cwd).arg("root").cwd(path).exec_with_output()); - return Ok(HgRepo) + Ok(HgRepo) } } -- 2.30.2